#异常
# 1.捕获异常
# try:
#     f = open("D:\python_Test/abc.txt","r",encoding="UTF-8")
# except:
#     print("出现打开文件异常")

# try:
#     print(name)
# except NameError as e:
#     print("未定义变量")
#     print(e)


# #2.捕获多个异常
# try:
#     # print(name)
#     1/0
# except (NameError,ZeroDivisionError) as e:
#     print("出现变量未定义或者除0")
#
# #3.捕获所有异常
try:
    1/0
    print(name)
except Exception as e:
    print("出现异常")
else:
    print("没有异常时，执行的代码")
finally:
    print("有没有异常，都会执行的代码")



